<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <!-- <base target="_blank"> -->
</head>
<body>
    <!-- <a href="https://www.baidu.com/">百度</a> -->

    <button>跳转到百度</button>
    <div></div>
    <script>
        // console.log(window.location)
        // console.log(document.location)
        
        const btnObj = document.querySelector("button")
        const divObj = document.querySelector("div")
        btnObj.addEventListener("click",function(){
            // window.location   或者 location

            location.href = 'https://www.baidu.com/'
        })

        let time =3;
        setInterval(function(){
            if(time!=0){
                divObj.innerText= '将在'+time+'秒后跳转到百度'
                time--;
            }else{
                location.href= 'https://www.baidu.com/' 
            }
        },1000)
    </script>
</body>
</html>